#define _CRT_SECURE_NO_WARNINGS 
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution
{
public:
    int numDecodings(string s)
    {
        int n = s.size();
        vector<int> dp(n);
        if (s[0] != '0')
        {
            dp[0] = 1;
            if (n > 1 && s[1] != '0') dp[1] += 1;
        }
        if (n > 1 && ((s[0] - '0') * 10 + (s[1] - '0')) >= 10 && ((s[0] - '0') * 10 + (s[1] - '0')) <= 26)
        {
            dp[1] += 1;
        }
        for (int i = 2; i < n; i++)
        {
            if (s[i] >= '1' && s[i] <= '9') dp[i] += dp[i - 1];
            if (((s[i] - '0') + (s[i - 1] - '0') * 10) >= 10 && ((s[i] - '0') + (s[i - 1] - '0') * 10) <= 26)
                dp[i] += dp[i - 2];
        }
        return dp[n - 1];
    }
};

int main()
{
    Solution s;
    string str = "1201234";
    cout << s.numDecodings(str);
    return 0;
}